package com.baizhi.service.impl;

import com.baizhi.annotation.InsertCacheAnnotation;
import com.baizhi.annotation.LogAnnotation;
import com.baizhi.annotation.LogType;
import com.baizhi.dao.CmfzGuruDao;
import com.baizhi.entity.CmfzGuru;
import com.baizhi.service.CmfzGuruService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;
@Service
@Transactional
public class CmfzGuruServiceImpl implements CmfzGuruService {
    @Autowired
    private CmfzGuruDao cmfzGuruDao;

    @Override
    @Transactional(readOnly = true)
    public Page<CmfzGuru> guruListByPage(int pageNo, int pageSize) {
        Page<CmfzGuru> page=new Page<>(pageNo,pageSize);
        Page<CmfzGuru> page1 = cmfzGuruDao.selectPage(page, null);

        return page1;
    }

    @InsertCacheAnnotation
    @LogAnnotation(value = "添加上师",type= LogType.INSERT)

    @Override
    public void insert(CmfzGuru cmfzGuru) {
        cmfzGuruDao.insert(cmfzGuru);
    }

    @Override
    public void delete(int id) {
        cmfzGuruDao.deleteById(id);
    }

    @Override
    public void update(CmfzGuru cmfzGuru) {
        cmfzGuruDao.updateById(cmfzGuru);
    }

    @Override
    public CmfzGuru selectOne(int id) {
        return  cmfzGuruDao.selectById(id);
    }
}
